#ifndef _core_dispatch_util_hpp_
#define _core_dispatch_util_hpp_

/** \file util.hpp
 *  \author Adrian Schweizer
 *  \created  $Sa 18 Aug 03:48:01 pm CEST 2007 schwadri@SchwadriComp.local$
 *  \modified $So 19 Aug 02:01:50 pm CEST 2007 schwadri@SchwadriComp.local$
 */

#include <boost/mpl/int.hpp>

namespace core {

    namespace dispatch {

        namespace util {

            /** \brief KeyValidator that accepts every key*/
            template<class Key>
                struct always_true
                {
                    template<class InputKey>
                        bool operator()(const InputKey& k)
                        {
                            return true;
                        }
                };

            /** \brief KeyRouter that returns the key shifted by a constant value
             *
             *  \par Template Parameters
             *  - \p Key the integral type of the key
             *  - \p offset the offset that will be substracted from the key. this is \a optional
             *       and defaults to 0
             */
            template<class Key, Key offset=0>
                struct default_router
                {
                    template<class InputKey>
                        Key operator()(const InputKey& k)
                        {
                            return static_cast<Key>(k)-offset;
                        }

                    typedef boost::mpl::int_<offset> first;
                };

        } // namespace util
    } // namespace dispatch
} // namespace core

#endif // _core_dispatch_util_hpp_
